#pragma once
#include <iostream>
#include <pthread.h>
#include <string>
#include <cstdio>

typedef void *(*fun_t)(void *);

class ThreadData
{
public:
    void* args_;
    std::string name_;
};
class Thread
{
public:
    Thread(int num,fun_t callBack,void* args):func_(callBack)
    {
        char Buffer[64];
        snprintf(Buffer,sizeof Buffer,"thread - %d", num);
        name_ = Buffer;

        tdata_.args_ = args;
        tdata_.name_ = name_;
    }   
    ~Thread()
    {}
    void start()
    {
        pthread_create(&tid_,nullptr,func_,(void*)&tdata_);
    }
    void join()
    {
        pthread_join(tid_,nullptr);
    }
    std::string name()
    {
        return name_;
    }
private:
    std::string name_;
    pthread_t tid_;
    ThreadData tdata_;
    fun_t func_;
};